/* mongodb数据库静态配置
 * @Author: Leil 
 * @Date: 2018-08-20 11:36:59 
 * @Last Modified by: Leil
 * @Last Modified time: 2018-09-05 17:06:22
 */
const config = require('config-lite')(__dirname)
const Mongolass = require('mongolass')
const mongolass = new Mongolass(config.mongodb)

// 管理员信息
exports.Admin = mongolass.model('Admin', {
    name: {type: 'string', required: true},
    password: {type: 'string', required: true}
})
// 根据用户名找到用户，用户名全局唯一
exports.Admin.createIndex({name: 1}, {unique: true}).exec()

// 文章类别信息
exports.Category = mongolass.model('Category', {
    title: {type: 'string', required: true},
    sort: {type: 'number', required: true}
})
exports.Category.createIndex({title: 1, sort: 1}, {unique: true}).exec()

// 文章信息
exports.Post = mongolass.model('Post', {
    title: {type: 'string', required: true},
    imgPath: {type: 'string', required: true},
    text: {type: 'string', required: true},
    postDescription: {type: 'string', required: true},
    categoryId: {type: 'string', required: true},
    categoryName: {type: 'string', required: true},
    updateTime: {type: 'string', required: true}
})
exports.Post.createIndex({title: 1}, {unique: true}).exec()